package main

import "fmt"

func strStr(haystack string, needle string) int {
	a := 0
	if len(haystack) < len(needle) {
		return -1
	}
	for i, _ := range haystack {
		if needle[0] != haystack[i] {
			a++
		} else if needle[0] == haystack[i] {
			if i+len(needle) > len(haystack) {
				return -1
			}
			if needle == haystack[i:i+len(needle)] {
				return a
			} else {
				a++
			}
		}
	}
	return -1

}

func main() {
	fmt.Println("0 :", strStr("hello", "hello"))
	fmt.Println("6 :", strStr("satbutsa", "sad"))
	fmt.Println("-1  :", strStr("leetcode", "leeto"))
	fmt.Println("4  :", strStr("hello", "o"))
	fmt.Println("-1  :", strStr("aaa", "aaaa"))
	fmt.Println("4  :", strStr("mississippi", "issip"))

}
